<?php
class Controller_App_Service extends Controller_App_Template
{
    public function __construct ($req, $res)
    {
        $this->template = "smarty:app/service/blank";
        parent::__construct($req, $res);
    }

    public function action_index ()
    {
        //
    }

    public function action_about ()
    {
        $this->template->set_filename("smarty:app/service/about");
    }
    
    // 签到
    public function action_sign()
    {
        $uid = $this->_uid;
        $result = App_Service::handle_sign($uid);
        $referrer = Arr::get($this->_post, 'referrer', '/');
        $this->request->redirect($referrer);
    }
    
    // 留言
    public function action_message()
    {
        $post = $this->request->post();
        if (! empty($post))
        {
            $uid = $this->_uid;
            $result = App_Service::handle_message($post ,$uid);
            $this->template->set('items', $result);
        }
        $this->template->set_filename("smarty:app/service/message");
    }

    public function action_report ()
    {
        $post = $this->request->post();
        if (! empty($post))
        {
            $result = App_Service::handle_feedback($post);
            $this->template->set('items', $result);
        }

        $this->template->set_filename("smarty:app/service/report");
    }

    public function action_app ($type = 'android')
    {
        $downloadUrl = Kohana::config('app.android.version.apkUrl');
        $this->request->redirect($downloadUrl);
    }

    public function action_download ()
    {
        $this->template->set_filename("smarty:app/service/download");
    }

}
